package com.zb.uniman.controller;

import com.zb.uniman.common.ErrorCode;
import com.zb.uniman.common.ResultMap;
import com.zb.uniman.model.SysUser;
import com.zb.uniman.service.LoginService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/*
  登录流程：
  user{id:"",username:"",password:""}
  根据id创建jwt返回前端
  认证通过token查到user对象，放行
   */
@RestController
@RequestMapping("/s")
public class securityController {
    @Autowired
    private LoginService loginService;

      /**
       *   127.0.0.1:8080/s/login
       * token：测试类生成 .其他请求需要，本请求不需要
       * post请求
       * 参数：
        {
            "id":"1",
            "userName":"bf",
            "password":"123456"
        }
       */
    @PostMapping("/login")
    public ResultMap securityLogin(@RequestBody SysUser user) {
        ResultMap resultMap = loginService.login(user);
        return resultMap;
    }

    @GetMapping("/hi")
    public ResultMap sayhi(){
        ResultMap<Object> resultMap = new ResultMap<>();
        resultMap.setCode(200);
        resultMap.setMsg("返回成功");
        return resultMap;
    }


}
